import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.TexturePaint;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JTextPane;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.IOException;
import javax.swing.JScrollPane;


public class VisualDico extends JFrame {
    private ManipDico manipdico = new ManipDico();
    
	private JPanel contentPane;
	private JTextField zonedeRech;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					VisualDico frame = new VisualDico();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public VisualDico() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		final JTextPane TextPane = new JTextPane();
		TextPane.setBounds(15, 123, 407, 108);
		
		final JScrollPane scrollPane = new JScrollPane(TextPane);
		scrollPane.setBounds(5, 123, 417, 128);
		/*
		final JTextPane TextPane = new JTextPane();
		TextPane.setBounds(15, 123, 407, 108);*/
		//contentPane.add(TextPane);
		//scrollPane.add(TextPane);
		contentPane.add(scrollPane);
		
		zonedeRech = new JTextField();
		zonedeRech.setBounds(5, 71, 300, 41);
		contentPane.add(zonedeRech);
		zonedeRech.setColumns(10);
		JButton btnNewButton = new JButton("Rechercher");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				try {
					String s= manipdico.Rech(new Mot(zonedeRech.getText().toLowerCase(), "fr", null)).getDef().getDefinition();
					TextPane.setText(s);
					
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
				
			}
		});
		btnNewButton.setBounds(315, 71, 107, 41);
		contentPane.add(btnNewButton);
		
	}
}
